package goleetcode

func countWords(words1 []string, words2 []string) int {
	// Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.
	strMap1 := make(map[string]int)
	strMap2 := make(map[string]int)

	for _, word := range words1 {
		strMap1[word]++
	}

	for _, word := range words2 {
		strMap2[word]++
	}

	res := 0
	for s, value := range strMap1 {
		if value == 1 && strMap2[s] == 1 {
			res++
		}
	}
	return res
}